function winPost(url,data){
	success=function(result){
		layer.alert("Success", {
			icon : 6
		}, function() {
			xadmin.close();
			xadmin.father_reload();
		});
	}
	apipost(url,data,success);
}

function winPut(url,data){
	success=function(result){
		layer.alert("Success", {
			icon : 6
		}, function() {
			xadmin.close();
			xadmin.father_reload();
		});
	}
	apiput(url,data,success);
}

function apipost(url,data,success,fail){
	xadmin.api(url,'POST',data,success,fail);
}

function apiput(url,data,success,fail){
	xadmin.api(url,'PUT',data,success,fail);
}

function apidelete(url,data,success,fail){
	xadmin.api(url,'DELETE',data,success,fail);
}

function actionDel(url) {
	var data = [];
    $("input:checkbox[name='id']:checked").each(function(i){
        data.push($(this).val());
	});
    if(data.length>0){
		layer.confirm('确认删除'+data.length+'条记录吗？', function(index) {
			success=function(result){
				location.reload();
			}
			apidelete(url,data,success);
		});
	}else{
		layer.alert("请选择要删除的记录", {
			icon : 6
		});
	}
}

function dateFormat(val){
	return val.replaceAll('-','').replaceAll(':','').replaceAll(' ','')
}

function convertEmptyStringToNull(str) {
    return str === '' ? null : str;
}

function isString(data) {
  return typeof data === 'string';
}

function convertFormParams(field) {
	var params={};
	for(var key in field){
		var val=field[key];
		if(isString(val)){
			if(val!=''){
				params[key]=val;
			}
		}else{
			params[key]=val;
		}
	}
	return params;
}

function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}

function showBigImage(img) {
	  layer.open({
	    type: 1,
	    title: false,
	    closeBtn: 0,
	    area: ['auto', 'auto'],
	    skin: 'layui-layer-nobg',
	    shadeClose: true,
	    content: '<img src='+img.src+' style="margin: auto;">'
	  });
}

function generateUUID() {
  return hexMD5('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
    var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
    return v.toString(16);
  }));
}